<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="string" uri="http://jakarta.apache.org/taglibs/string-1.1" %>
<%@ taglib uri="/WEB-INF/tlds/pagination.tld" prefix="pagination" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<html>
<head>
    <title>Bettersoft Portal</title>
    <link href="/common/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/common/js/common.js"></script>
    <script type='text/javascript' src="/common/dwr/engine.js"></script>
    <script type='text/javascript' src="/common/dwr/util.js"></script>
    <script type="text/javascript">
        // 페이지 이동을 처리한다.
        function goListPage(page) {
            var TheForm = document.frm;
            TheForm.currentPage.value = page;
            TheForm.nextTarget.value = 'noticeBoardList';
            TheForm.action = './noticeBoardList.do';
            TheForm.submit();
        }

        // 검색어로 리스트를 출력한다.
        function jsSearchList() {
            var TheForm = document.frm;
            TheForm.title.value = TheForm.search_title.value;
            TheForm.writer_id.value = TheForm.search_writer.value;
            TheForm.writer_nick_name.value = TheForm.search_nickName.value;
            TheForm.content.value = TheForm.search_content.value;
            TheForm.nextTarget.value = 'noticeBoardList';
            TheForm.action = './getBoardListBySearchword.do';
            TheForm.submit();
        }

        // Board List 페이지로 이동한다.
        function jsBoardList() {
            var TheForm = document.frm;
            TheForm.nextTarget.value = "noticeBoardList";	// page name
            TheForm.action = "./noticeBoardContent.do";
            TheForm.submit();
        }

        // Community Board List 페이지로 이동한다.
        function jsCommunityBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "communityBoardList";	// page name
            TheForm.action = "./communityBoardList.do";
            TheForm.submit();
        }

        // Member List 페이지로 이동한다.
        function jsMemberList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "memberList";	// page name
            TheForm.action = "./memberList.do";
            TheForm.submit();
        }

        // Photo Board List 페이지로 이동한다.
        function jsPhotoBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "photoBoardList";	// page name
            TheForm.action = "./photoBoardList.do";
            TheForm.submit();
        }

        // Notice Board List 페이지로 이동한다.
        function jsNoticeBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "noticeBoardList";	// page name
            TheForm.action = "./noticeBoardList.do";
            TheForm.submit();
        }

        // Contact Us 페이지로 이동한다.
        function jsContactUs() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "contactus";	// page name
            TheForm.action = "./contactus.do";
            TheForm.submit();
        }

        // FAQ 페이지로 이동한다.
        function jsFAQ() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "faq";	// page name
            TheForm.action = "./faq.do";
            TheForm.submit();
        }

        // 글 작성 Action 을 수행한다.
        function jsUpdateAction() {
            var TheForm = document.writeFrm;
            if(trim(TheForm.title.value) == ""){
                alert('<spring:message code="noticeBoardUpdate.alert1" />');
                TheForm.title.value = "";
                TheForm.title.focus();
                return false;

            }else if(trim(TheForm.content.value) == ""){
                alert('<spring:message code="noticeBoardUpdate.alert2" />');
                TheForm.content.value = "";
                TheForm.content.focus();
                return false;

            }else{
                TheForm.nextTarget.value = "noticeBoardList";	// page name
                TheForm.action = "./noticeBoardUpdateAction.do";
                TheForm.submit();
            }
        }

        function jsImgChanged(){
            var TheForm = document.writeFrm;
            TheForm.img_changed.value = "yes";	// img changed.
            // 원본 img 영역을 숨긴다..
            document.getElementById("org_img_show").style.display = "none";
        }
    </script>
</head>

<body>
<div id="wrapper">
    <!------------------------------ top 시작-------------------------------------->
    <%@include file="portalHeader.jsp" %>
    <!------------------------------ top 끝-------------------------------------->
    <div class="sub_content">
        <form name="writeFrm" method="POST" enctype="multipart/form-data">
            <input type="hidden" name="notice_board_no" value="${board.notice_board_no}">
            <input type="hidden" name="writer_id" value="<%=s.getAttribute("userId")%>">
            <input type="hidden" name="writer_nick_name" value="<%=s.getAttribute("nickName")%>">
            <input type="hidden" name="writer_password" value="">
            <input type="hidden" name="writer_email" value="<%=s.getAttribute("email")%>">
            <input type="hidden" name="add_file_yn" value="">
            <input type="hidden" name="nextTarget" value="">
            <input type="hidden" name="currentPage" value="${currentPage}">
            <input type="hidden" name="img_changed" value="no">

            <img src="/images/intro/sub_title01.gif" />
            <table class="notice_tb">
                <tr>
                    <td class="notice_tb_headfirst03"><spring:message code="noticeBoardUpdate.writer_id" /> : <%=s.getAttribute("userId")%></td>
                    <td width="16%" class="notice_tb_head02"><spring:message code="noticeBoardUpdate.nick_name" /> : <%=s.getAttribute("nickName")%></td>
                    <td width="53%" class="notice_tb_head02"><spring:message code="noticeBoardUpdate.email" /> : <%=s.getAttribute("email")%></td>
                    <td width="14%" class="notice_tb_headlast">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="4" class="write_tb"><spring:message code="noticeBoardUpdate.title" />
                        <input name="title" type="text" size="179" class="write_title" value="${board.title}"/></td>
                </tr>
                <tr>
                    <td colspan="4" class="write_tb"><textarea name="content" cols="45" rows="20" class="write_textarea">${board.content}</textarea></td>
                </tr>
                <c:set value="Y" var="addFile"/>
                <%-- 이전 업로드했던 이미지가 있을 경우.--%>
                <c:if test="${board.add_file_yn == addFile}">
                    <tr>
                        <td id="org_img_show"  colspan="4" class="write_tb02">
                                <%-- 해당 이미지의 원본 이름을 보여주고 클릭시 다운로드 하도록 한다.--%> <%--우측 x 단추를 눌러 원본 이미지를 삭제할 수 있다.--%>
                            <a href="/download.do?tFileName=${board.add_file_temp_name}&oFileName=${board.add_file_original_name}">${board.add_file_original_name}</a>&nbsp;&nbsp;${board.add_file_size}&nbsp;byte <a href="javascript:jsImgChanged()"><img src="/images/intro/btn_del02.gif" /></a>
                        </td>
                    </tr>
                </c:if>
                <tr>
                    <td colspan="4" class="write_tb02"><spring:message code="noticeBoardUpdate.file" />
                        <input name="fileUp" type="file" size="50" class="write_attach"  onchange="jsImgChanged();" />
                        <img src="/images/intro/btn_del03.gif" class="write_btn" /></td>
                </tr>
            </table>
            <!---------------------------------------- 버튼 -------------------------------------->
            <div class="btn_right02">
                <a href="javascript:jsUpdateAction()"><img src="/images/intro/btn_write02.gif" /></a>
            </div>
            <div class="btn_left">
                <a href="javascript:jsNoticeBoardList()"><img src="/images/intro/btn_list.gif" /></a>
            </div>
        </form>
    </div>
    <!------------------------------ 하위메뉴 시작-------------------------------------->
    <%@include file="portalFooter.jsp" %>
    <!------------------------------ 하위메뉴 끝-------------------------------------->
</div>
</body>
</html>